<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>更改密码</title>
<script type="text/javascript" src="<%=basePath%>js/jquery-2.0.3.min.js"></script>
<style type="text/css">
*{
font-family: '微软雅黑';
font-size: 15px;
}
</style>
<script type="text/javascript">
function checkPassword(){
	document.getElementById("repPwdMsg").innerHTML="";
	var password=$("#password").val();
	var userEmail=$("#userEmail").val();
	$.ajax({
         type:'post',
         url:'<%=basePath%>user/user_checkPwd',
         data:{userEmail:userEmail,userPwd:password},
         dataType:'json',
         success:function(data){
        	 if(data[0].msg=="0"){
	        	 document.getElementById("passwordMsg").innerHTML="<span style='color:red'>密码输入错误</span>";
		         }else{
		        	 document.getElementById("passwordMsg").innerHTML="<span style='color:green'>密码输入正确</span>";
			         }
             }
		});
}
function checkPwd(){
	document.getElementById("repPwdMsg").innerHTML="";
	var userPwd=$("#userPwd").val();
	if(userPwd.length==null){
		 document.getElementById("userPwdMsg").innerHTML="<span style='color:red'>密码不能为空</span>";
		}else{
                if(userPwd.length<6||userPwd.length>10){
                	document.getElementById("userPwdMsg").innerHTML="<span style='color:red'>密码长度为6到10位</span>";
                    }
			}
}
function checkRepPwd(){
	document.getElementById("repPwdMsg").innerHTML="";
	var repPwd=$("#repPwd").val();
	var userPwd=$("#userPwd").val();
	if(repPwd!=userPwd){
		document.getElementById("repPwdMsg").innerHTML="<span style='color:red'>两次输入密码不一致</span>";
		}
}
</script>
</head>
<body>
<form action="user_updatePwd" method="post"  target="_parent">
<s:hidden id="userEmail" name="userEmail" value="%{user.userEmail}"></s:hidden>
<s:hidden name="userId" value="%{user.userId}"></s:hidden>
<div style="width: 700px;height: 300px;margin: 20px auto;background-color: #f2f2f2; border: 1px solid #bdbdbd;">
<table>
<tr height="40px;">
<td width="100px;">原始密码：</td>
<td width="300px;"><s:textfield theme="simple" id="password" name="password" onblur="checkPassword()"  placeholder="请输入原始密码" style="width:90%;height:30px;" ></s:textfield></td>
<td width="300px;" id="passwordMsg"></td>
</tr>
<tr height="40px;">
<td width="100px;">新密码：</td>
<td width="300px;"><s:password theme="simple" name="userPwd" onblur="checkPwd()" id="userPwd" placeholder="请输入新密码" style="width:90%;height:30px;" ></s:password></td>
<td width="300px;" id="userPwdMsg"></td>
</tr>
<tr height="40px;">
<td width="100px;">密码确认：</td>
<td width="300px;"><s:password theme="simple" id="repPwd" onblur="checkRepPwd()" placeholder="请再次输入新密码" style="width:90%;height:30px;" ></s:password></td>
<td width="300px;" id="repPwdMsg"></td>
</tr>
<tr height="40px;">
<td width="100px;"></td>
<td width="300px;"><input type="submit" value="保存" style="width: 100px;height: 40px;background-color: #1e90ff; color: white;"/>&nbsp;&nbsp;<input type="reset" value="重置" style="width: 100px;height: 40px;"/></td>
<td width="300px;" align="left"></td>
</tr>
</table>
</div>
</form>
</body>
</html>